package com.vividsolutions.jts.addons.simulate;

public class Reader {

	char[] chars = null;
	int index = 0;

	public Reader(String wellKnownText) {
		chars = wellKnownText.toCharArray();
	}

	public void close() {
		chars = null;
		index = 0;
	}

	public int read() {
		return chars[index++];
	}

	public static char[] copyOf(char[] original, int newLength) {
		if (newLength < 0)
			throw new NegativeArraySizeException("The array size is negative.");
		char[] newArray = new char[newLength];
		for (int i = 0; i < newArray.length; i++) {
			if (i < original.length) {
				newArray[i] = original[i];
			} else {
				newArray[i] = '\u0000';
			}
		}
		return newArray;
	}

}
